// Reading a text-file one character at a time using a scanner
import java.io.*;
import java.util.Scanner;
public class FileReadChar3{
  public static void main(String[] args) throws IOException{
    FileInputStream instream = new FileInputStream("input.txt");
    Scanner fscanner = new Scanner(instream);
    FileOutputStream outstream = new FileOutputStream("output3.txt");
    PrintWriter pwriter = new PrintWriter(outstream);
    
    int count = 0;
    char ch;
    String  str;
    while(fscanner.hasNextLine()){
        str = fscanner.nextLine();       
        for(int k = 0; k < str.length(); k++){
            ch = str.charAt(k);
            if(Character.isLowerCase(ch)){
               count++;
               ch = Character.toUpperCase(ch);
            }
            pwriter.print(ch);
        }
        pwriter.println();    //generate new line
    } 
    
    fscanner.close();
    pwriter.close();
    System.out.printf("The number of lowercase letters in input.txt is %d%n", count);
    System.out.println("The file output3.txt has been created . . . ");
  }
}
